﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace admin.two
{
    public partial class updatepwd : UserControl
    {
        ServiceReference1.Service1Client sc;

        public updatepwd()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(updatepwd_Loaded);
            this.bt_updatepwd.Click += new RoutedEventHandler(bt_updatepwd_Click);
        }

        void bt_updatepwd_Click(object sender, RoutedEventArgs e)
        {
            if (pwb_ad_newpwd_check.Password == pwb_ad_newpwd.Password)
            {
                sc.updatepwdAsync(pwb_oldpwd.Password, pwb_ad_newpwd.Password);
            }
        }

        void sc_updatepwdCompleted(object sender, admin.ServiceReference1.updatepwdCompletedEventArgs e)
        {
            bool sum = e.Result;
            if (sum)
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("操作失败,可能密码是错误的");
            }
        }

        void updatepwd_Loaded(object sender, RoutedEventArgs e)
        {
            sc = serverManager.getPox();
            sc.updatepwdCompleted += new EventHandler<admin.ServiceReference1.updatepwdCompletedEventArgs>(sc_updatepwdCompleted);
        }
    }
}
